//
//  Header_Type1_TableViewCell.swift
//  Pods
//
//  Created by eme on 2017/4/1.
//
//
/*
 owner:gyh
 update:2016年11月23日16:14:12
 info: 订单-订单详情Cell(支付倒计时Cell)
 */
import UIKit

class Header_Type1_TableViewCell: UITableViewCell {

    @IBOutlet weak var TimeLabel: UILabel!
    var timer = Timer()
    var customDate:(hour:Int,minute:Int,second:Int)?
    var orderid:String?
    var payid:String?
    var changOrderStatus:Change_OrderStatus?
    
    override func awakeFromNib() {
        super.awakeFromNib()
        TimeLabel.normal_fontSize(14)
        timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector:#selector(Header_Type1_TableViewCell.timeheader), userInfo: nil, repeats: true)
    }
    func timeheader(){
        
        if self.customDate!.hour <= 0 &&  self.customDate!.minute <= 0 && self.customDate!.second <= 0{
            
            timer.invalidate()
            print("这是待付款倒计时")
            self.TimeLabel.text = "支付剩余\(0)时\(0)分\(0)秒"
            
        }else{
            
            if self.customDate?.second == 0{
                
                if customDate?.minute == 0{
                    
                    customDate?.hour -= 1
                    customDate?.minute = 59
                    customDate?.second = 59
                }else{
                    customDate?.minute -= 1
                    customDate?.second = 59
                }
            }else{
                customDate?.second -= 1
            }
            
            self.TimeLabel.text = "支付剩余\(customDate!.hour)时\(customDate!.minute)分\(customDate!.second)秒"
            
        }
        
        
        
    }
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}
